package com.baidu.shoppingmall.attribute.service.impl;

import com.baidu.shoppingmall.attribute.dao.AttributeCategoryDao;
import com.baidu.shoppingmall.attribute.domain.AttributeCategoryDTO;
import com.baidu.shoppingmall.attribute.domain.AttributeCategoryPO;
import com.baidu.shoppingmall.attribute.service.AttributeCategoryService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
/**
 * author 杨朋
 */
public class AttributeCategoryServiceImpl extends ServiceImpl<AttributeCategoryDao, AttributeCategoryPO> implements AttributeCategoryService {


    @Autowired
    private AttributeCategoryDao attributeCategoryDao;

    /**
     * 查询所有的类别和属性
     * @return
     */
    @Override
    public List<AttributeCategoryDTO> getCategoryProperties() {
        List<AttributeCategoryPO> attributeCategoryPoList = attributeCategoryDao.getCategoryProperties();
        List<AttributeCategoryDTO> attributeCategoryDtoList = new ArrayList<>(attributeCategoryPoList.size());
        attributeCategoryPoList.forEach(po->attributeCategoryDtoList.add(po.clone(AttributeCategoryDTO.class)));
        return attributeCategoryDtoList;
    }
}
